<!DOCTYPE html>
<html>
<head>
	<title>jQuery MiniColors</title>
	<meta name="description" content="A tiny color picker built on jQuery" />
	<meta charset="utf-8" />
	<meta name="viewport" content="initial-scale=1.0" />
	<link rel="stylesheet" href="jquery.minicolors.css" />
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
	<script src="jquery.minicolors.js"></script>
	<style>
		
		HTML,
		BODY {
			padding: 0;
			margin: 0;
		}
		
		BODY {
			font: 14px sans-serif;
			color: #666;
			line-height: 1.7;
			background: #F8F8F8;
			padding: 0 20px;
			padding-bottom: 32px;
		}
		
		H1, H2, H3 {
			font-family: Georgia, serif;
			font-weight: normal;
			color: black;
			overflow: hidden;
			text-overflow: ellipsis;
		}
		
		H1, H2, H3, P {
			margin: 20px 0;
		}
		
		A {
			color: #08C;
		}
		
		A:hover {
			color: #0BE;
		}
		
		PRE,
		CODE {
			background: #F8F8F8;
			padding: 2px;
		}
		
		PRE {
			overflow: hidden;
			text-overflow: ellipsis;
			padding: 10px;
			margin: 30px 0;
		}
		
		.alert {
			background: #FFFCCC;
			color: black;
			padding: 1px 10px;
			margin: 30px 0;
		}
		
		#main {
			max-width: 800px;
			background: white;
			border: solid 1px #DDD;
			box-shadow: 0 0 30px rgba(0, 0, 0, .05);
			padding: 30px;
			margin: 20px auto;
		}
		
		.example {
			background: #F8F8F8;
			padding: 10px;
			margin: 20px 0;
		}
		
		#console {
			position: fixed;
			left: 0;
			right: 0;
			bottom: 0;
			height: 32px;
			font-family: monospace;
			line-height: 32px;
			text-align: center;
			background: black;
			color: white;
			z-index: 100;
			-moz-transition: all .5s;
			-ms-transition: all .5s;
			-webkit-transition: all .5s;
			transition: all .5s;
			opacity: 0;
		}
		
		#console.busy {
			opacity: .85;
		}
		
	</style>
	
	<script>
		
		$(document).ready( function() {
			
			var consoleTimeout;
			
			// Display the results of the change callback on any minicolors input
			$('INPUT[type=minicolors]').on('change', function() {
				
				var input = $(this),
					hex = input.val(),
					opacity = input.attr('data-opacity'),
					text;
				
				// Generate text to show in console
				text = hex ? hex : 'transparent';
				if( opacity ) text += ', ' + opacity;
				text += ' / ' + $.minicolors.rgbString(input)
				
				// Show text in console; disappear after a few seconds
				$('#console').text(text).addClass('busy');
				clearTimeout(consoleTimeout);
				consoleTimeout = setTimeout( function() {
					$('#console').removeClass('busy');
				}, 3000);
				
			});
			
			// Adding controls dynamically
			$('#add-one').on('click', function() {
				
				// Just add an <input type="minicolors" /> control anywhere in your page
				$('#add-one-result').append('<input type="minicolors" data-slider="' + $('#add-one-slider').val() + '" value="#ff6600" /><br /><br />');
				
				// ...then call $.minicolors.init() to activate the control
				$.minicolors.init();
				
			});
			
		});
		
	</script>
	
</head>
<body>
	
	<div id="main">
		<h1>jQuery MiniColors 2.0 beta</h1>
		<p>
			A project by Cory LaViska of <a href="http://www.abeautifulsite.net/">A Beautiful Site</a>. 
		</p>
		<p>
			MiniColors is a tiny color picker built on jQuery. It's easy to use and works 
			well on touch-enabled devices. Completely re-written for 2.0.
		</p>
		<div class="alert">
			<p>
				The MiniColors API was completely overhauled in 2.0. You will need to change your 
				code if you are upgrading from a previous version!
			</p>
		</div>
		
		<!-- Download -->
		<h2 id="download">Download</h2>
		<p>
			You can <a href="https://github.com/claviska/jquery-miniColors">download the source</a> 
			on GitHub. Help contribute to this project by posting bug reports, feature requests, and 
			code improvements!
		</p>
		
		<h2 id="usage">Usage</h2>
		<p>
			The plugin will automatically initialize all inputs of type <code>minicolors</code>: 
		</p>
		<pre>&lt;input type="minicolors" /&gt;</pre>
		<p>
			This results in the default color picker: 
			<input type="minicolors" />
		</p>
		<p>
			To set an initial value, use the <code>value</code> attribute:
		</p>
		<pre>&lt;input type="minicolors" value="#00cc00" /&gt;</pre>
		<p>
			This results in the default color picker with a preset value: 
			<input type="minicolors" value="#00cc00" />
		</p>
		<p>
			You can obtain the selected value any time by grabbing the original <code>input</code> 
			element's <code>value</code>.
		</p>
		
		<!-- Options -->
		<h2 id="options">Options</h2>
		<p>
			Options are set for each control using one or more of the HTML5 <code>data-</code> 
			attributes mentioned below.
		</p>
		
		<h3>Slider Variations</h3>
		<p>
			MiniColors has four slider variations. Set the <code>data-slider</code> attribute 
			to use them.  Valid options are <code>hue</code> (default), <code>saturation</code>, 
			<code>brightness</code>, and <code>wheel</code>.
		</p>
		<pre>&lt;input type="minicolors" data-slider="saturation" /&gt;</pre>
		
		<p>
			<input type="minicolors" value="#d7e036" data-slider="hue" />
			<input type="minicolors" value="#00a9bf" data-slider="saturation" />
			<input type="minicolors" value="#b340ff" data-slider="brightness" />
			<input type="minicolors" value="#e87262" data-slider="wheel" />
		</p>
		
		<h3>Default Values</h3>
		<p>
			Use the <code>data-default</code> attribute to force a default hex value. Try clearing 
			the box—it will revert to its default value. Note that the default value does not have 
			to be the same as the initial value (set with the <code>value</code> attribute).
		</p>
		<pre>&lt;input type="minicolors" data-default="#ffffff" /&gt;</pre>
		<p>
			<input type="minicolors" data-default="#ffffff" />
		</p>
		
		<h3>No Text Field</h3>
		<p>
			Turn the color picker into a stand-alone color swatch by setting <code>data-textfield</code> 
			to <code>false</code>:
		</p>
		<pre>&lt;input type="minicolors" data-textfield="false" /&gt;</pre>
		<p>
			<input type="minicolors" value="#ff6600" data-textfield="false" data-slider="hue" />
			<input type="minicolors" value="#29cf37" data-textfield="false" data-slider="saturation" />
			<input type="minicolors" value="#b437c7" data-textfield="false" data-slider="brightness" />
			<input type="minicolors" value="#00a4d1" data-textfield="false" data-slider="wheel" />
		</p>
		
		<h3>Opacity Slider</h3>
		<p>
			Enable the opacity slider by adding the <code>data-opacity</code> attribute:
		</p>
		<pre>&lt;input type="minicolors" data-opacity=".75" /&gt;</pre>
		<p>
			<input type="minicolors" value="#4471a3" data-opacity=".75" />
		</p>
		<p>
			To obtain the opacity value, grab the <code>data-opacity</code> attribute of your input 
			element. Keep in mind that this value will not submit along with other form data, so it's 
			best to use the <code>change</code> callback to update a hidden element in your form if 
			you need it to be submitted.
		</p>
		
		<h3>Inline Controls</h3>
		<p>
			Force the color picker to appear inline by setting <code>data-control</code> to <code>inline</code>:
		</p>
		<pre>&lt;input type="minicolors" data-control="inline" /&gt;</pre>
		<p>
			<input type="minicolors" value="#3c9641" data-control="inline" data-slider="hue" data-style="margin: 10px;" />
			<input type="minicolors" value="#d49f00" data-control="inline" data-slider="saturation" data-style="margin: 10px;" />
			<input type="minicolors" value="#5cb8ff" data-control="inline" data-slider="brightness" data-style="margin: 10px;" />
			<input type="minicolors" value="#5bbf4c" data-control="inline" data-slider="wheel" data-style="margin: 10px;" />
		</p>
		
		<h3>Dropdown Position</h3>
		<p>
			Change the position of the dropdown panel by setting the <code>data-position</code> 
			attribute.  Valid options are <code>top</code>, <code>left</code>, and <code>top left</code>.
		</p>
		<pre>&lt;input type="minicolors" data-position="top" /&gt;</pre>
		<p>
			<input type="minicolors" data-position="top" data-opacity=".5" />
		</p>
		
		<h3>Swatch Position</h3>
		<p>
			Force the color swatch to appear on the left by setting <code>data-swatch-position</code> 
			to <code>left</code>:
		</p>
		<pre>&lt;input type="minicolors" data-swatch-position="left" /&gt;</pre>
		<p>
			<input type="minicolors" data-swatch-position="left" />
		</p>
		
		<h3>Classes &amp; Styles</h3>
		<p>
			Use <code>data-class</code> and <code>data-style</code> to apply classes and styles 
			to the parent element of the resulting control:
		</p>
		<pre>&lt;input type="minicolors" data-class="my-class" data-style="margin: 20px;" /&gt;</pre>
		
		<!-- Utility Functions -->
		<h2 id="utility-functions">Utility Functions</h2>
		<h3><code>$.minicolors.init()</code></h3>
		<p>
			Call this function to initialize controls that are created dynamically. You do not 
			need to specify a selector when calling this function.  Example:
		</p>
		
		<div class="example">
			<p>
				<select id="add-one-slider">
					<option value="hue">Hue Picker</option>
					<option value="saturation">Saturation Picker</option>
					<option value="brightness">Brightness Picker</option>
					<option value="wheel">Wheel Picker</option>
				</select>
				<button id="add-one">Add it!</button>
			</p>
			<div id="add-one-result"></div>
		</div>
		
		<h3><code>$.minicolors.remove(<em>input</em>)</code></h3>
		<p>
			Call this function to remove a control from the DOM. (You can also remove any of the 
			control's parent elements with the same effect.)
		</p>
		
		<h3><code>$.minicolors.refresh()</code></h3>
		<p>
			Call this function if you programmatically change the value of one or more controls.
		</p>
		
		<h3><code>$.minicolors.show(<em>input</em>)</code></h3>
		<p>
			Show the control attached to the specified <code>input</code> element. Only 
			one control may be shown at once. (Doesn't apply to inline controls.)
		</p>
		
		<h3><code>$.minicolors.hide()</code></h3>
		<p>
			Hides any control that may be showing. (Doesn't apply to inline controls.)
		</p>
		
		<h3><code>$.minicolors.rgbObject(<em>input</em>)</code></h3>
		<p>
			Returns an object with <code>r</code>, <code>g</code>, <code>b</code>, and 
			<code>a</code> properties. The <code>a</code> property will only be present 
			if opacity is enabled on the specified control.
		</p>
		
		<h3><code>$.minicolors.rgbString(<em>input</em>)</code></h3>
		<p>
			Returns an RGB or RGBA string suitable for use in your CSS. If opacity is 
			enabled on the specified control, an RGBA string will be returned.  Otherwise 
			an RGB string will be returned.
		</p>
		
		<!-- Callbacks -->
		<h2 id="callbacks">Callbacks</h2>
		<h3><code>change</code></h3>
		<p>
			Attach your <code>change</code> callback to the original <code>input</code> element. 
			You can access the value and opacity of the control using the <code>value</code> and 
			<code>data-opacity</code> attributes, respectively.
		</p>
		<p>
			To convert a control's hex value to RGB or RGBA, use the 
			<code>$.minicolors.rgbObject()</code> or <code>$.minicolors.rgbString()</code> 
			utility functions.
		</p>
		
		<!-- Settings -->
		<h2 id="settings">Settings</h2>
		<p>
			Adjust plugin defaults by setting <code>$.minicolors.settings.<em>settingName</em></code>, 
			where <code><em>settingName</em></code> is one of the following:
		</p>
		
		<h3><code>animationSpeed</code> &amp; <code>animationEasing</code></h3>
		<p>
			The animation speed and easing effect to use when making a color selection. 
			Defaults to <code>100</code> (milliseconds) and <code>swing</code>, respectively.
			Set <code>animationSpeed</code> to <code>0</code> to disabled animation.
		</p>
		
		<h3><code>defaultSlider</code></h3>
		<p>
			Sets the slider variation for all controls that don't specify it through 
			<code>data-slider</code>. Default value is <code>hue</code>.
		</p>
		
		<h3><code>letterCase</code></h3>
		<p>
			Forces the hex color's letter case to uppercase or lowercase.  Possible values 
			are <code>lowercase</code> (default) and <code>uppercase</code>.
		</p>
		
		<h3><code>hideSpeed</code> &amp; <code>showSpeed</code></h3>
		<p>
			The hide/show speed for dropdown controls. Default is <code>100</code> (milliseconds).
		</p>
		
		<!-- Styling Tips -->
		<h2 id="styling-tips">Styling Tips</h2>
		<p>
			If you change the <code>input</code> element's height or width via CSS, you'll also 
			need to adjust certain style properties in <code>.minicolors-swatch</code>, 
			<code>.minicolors-panel</code>, <code>.minicolors-position-top</code>, and 
			<code>.minicolors-position-left</code>.
		</p>
	</div>
	
	<div id="console"></div>

</body>
</html>